import Vue from 'vue'
import App from './App.vue'

Vue.config.productionTip = false

let app;
function render(props){
  const { container } = props;
  app = new Vue({
    render: h => h(App),
  })
  // 如果是qiankun环境，就挂载到主应用中的container上，否则挂载到#app上
  app.$mount(container ? container.querySelector('#app') :'#app')
}

// 判断是否是qiankun环境
if(!window.__POWERED_BY_QIANKUN__){
  render({})
}


export async function bootstrap(props){
  console.log(props,'vue bootstrap');
  props.test && Vue.component('test', props.test);
}

export async function mount(props){
  render(props)
  console.log(props,'vue mount');
}

export async function unmount(){
  console.log('vue unmount');
  app.$destroy();
}
